package com.xcroot.chapter04;

import java.util.Scanner;

/**
 * Created by CRoot on 2017/10/12.
 */

class Student {
    private String Name, StuNum;
    private double MathScores, ChinesScores, EnglishScores;

    public Student(String name, String stuNum, double mathScores, double chinesScores, double englishScores) {
        Name = name;
        StuNum = stuNum;
        MathScores = mathScores;
        ChinesScores = chinesScores;
        EnglishScores = englishScores;
    }

    public String getName() {
        return Name;
    }

    public String getStuNum() {
        return StuNum;
    }

    public double getMathScores() {
        return MathScores;
    }

    public double getChinesScores() {
        return ChinesScores;
    }

    public double getEnglishScores() {
        return EnglishScores;
    }

    public double getAllScores() {
        return this.ChinesScores + this.getEnglishScores() + this.getMathScores();
    }
}

public class StudentTest {
    public static void main(String[] args) {
        Student[] students = new Student[10];
        Scanner sc = new Scanner(System.in);
        try {
            for (int i = 0; i < 10; i++) {
                println("请输入第" + (i + 1) + "个学生的姓名：");
                String inName = sc.next();
                println("请输入第" + (i + 1) + "个学生的学号：");
                String stuNum = sc.next();
                println("请输入第" + (i + 1) + "个学生的数学成绩：");
                double inMath = sc.nextDouble();
                println("请输入第" + (i + 1) + "个学生的语文成绩：");
                double inChinese = sc.nextDouble();
                println("请输入第" + (i + 1) + "个学生的英语成绩：");
                double inEnglish = sc.nextDouble();
                students[i] = new Student(inName, stuNum, inMath, inChinese, inEnglish);
            }
            println("输入完成！");
            while (true) {
                println("--------------------------------");
                println("请输入你要查询的学号");
                String num = sc.next();
                for (int i = 0; i < 10; i++) {
                    //println(students[i].getStuNum());
                    if (students[i].getStuNum().equals(num)) {
                        println(students[i].getStuNum() + " 学生的姓名：" + students[i].getName());
                        println(students[i].getStuNum() + " 学生的数学成绩：" + students[i].getMathScores());
                        println(students[i].getStuNum() + " 学生的语文成绩：" + students[i].getChinesScores());
                        println(students[i].getStuNum() + " 学生的英语成绩：" + students[i].getEnglishScores());
                        println(students[i].getStuNum() + " 学生的总成绩：" + students[i].getAllScores());
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sc.close();
        }
    }

    public static void println(String msg) {
        System.out.println(msg);
    }
}
